﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xna.Framework;

namespace XNAGuiLib.Core.System
{
    /// <summary>
    /// class provides static method to change the cursor of a Window.Forms.Form of a Microsoft.Xna.Framework.Game
    /// </summary>
    public class GameCursor
    {
        /// <summary>
        /// the windows-known arrow cursor for simple clicking (default)
        /// </summary>
        public static Cursor Arrow
        {
            get { return Cursors.Arrow; }
        }

        /// <summary>
        /// the windows-known arrow with a litte sand-clock beside
        /// </summary>
        public static Cursor ArrowLoading
        {
            get { return Cursors.AppStarting; }
        }

        /// <summary>
        /// the windows-known arrow with a litte question mark beside
        /// </summary>
        public static Cursor ArrowHelp
        {
            get { return Cursors.Help; }
        }

        /// <summary>
        /// a cross-hair like cursor (cross with symmetric legs)
        /// </summary>
        public static Cursor Cross
        {
            get { return Cursors.Cross; }
        }

        /// <summary>
        /// the default cursor of the GameCursor class (is set to 'Arrow')
        /// </summary>
        public static Cursor Default
        {
            get { return GameCursor.Arrow; }
        }

        /// <summary>
        /// the windows-known hand for drag and drop
        /// </summary>
        public static Cursor Hand
        {
            get { return Cursors.Hand; }
        }

        /// <summary>
        /// a no access/no action cursor (circle with line through)
        /// </summary>
        public static Cursor Forbidden
        {
            get { return Cursors.No; }
        }

        /// <summary>
        /// the windows-known sand-clock for loading
        /// </summary>
        public static Cursor Loading
        {
            get { return Cursors.WaitCursor; }
        }

        /// <summary>
        /// move cursor for all directions
        /// </summary>
        public static Cursor Move
        {
            get { return Cursors.NoMove2D; }
        }

        /// <summary>
        /// move cursor for the eastern direction
        /// </summary>
        public static Cursor MoveEast
        {
            get { return Cursors.PanEast; }
        }

        /// <summary>
        /// move cursor for the southern direction
        /// </summary>
        public static Cursor MoveSouth
        {
            get { return Cursors.PanSouth; }
        }

        /// <summary>
        /// move cursor for the northern direction
        /// </summary>
        public static Cursor MoveNorth
        {
            get { return Cursors.PanNorth; }
        }

        /// <summary>
        /// move cursor for the western direction
        /// </summary>
        public static Cursor MoveWest
        {
            get { return Cursors.PanWest; }
        }

        /// <summary>
        /// sizing cursor for resizing to all directions
        /// </summary>
        public static Cursor Size
        {
            get { return Cursors.SizeAll; }
        }

        /// <summary>
        /// sizing cursor for resizing to horizontal (east and west) direction
        /// </summary>
        public static Cursor SizeHorizontal
        {
            get { return Cursors.SizeWE; }
        }

        /// <summary>
        /// sizing cursor for resizing to vertical (north and south) direction
        /// </summary>
        public static Cursor SizeVertical
        {
            get { return Cursors.SizeNS; }
        }

        /// <summary>
        /// set the cursor for the game to the given one
        /// </summary>
        /// <param name="game">game to change the cursor for</param>
        /// <param name="cursor">the new cursor for the game</param>
        public static void Set(Game game, Cursor cursor)
        {
            Form gameForm = (Form)Form.FromHandle(game.Window.Handle);
            gameForm.Cursor = cursor;
        }

        /// <summary>
        /// reset the cursor for the game to default
        /// </summary>
        /// <param name="game">game to change the cursor for</param>
        public static void Reset(Game game)
        {
            Form gameForm = (Form)Form.FromHandle(game.Window.Handle);
            gameForm.Cursor = GameCursor.Default;
        }
    }
}
